%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% APPENDIX: PRESENT SPQIV MEDIAN REGRESSION TABLES

% "DEFORESTATION IN THE AMAZON:
% A UNIFIED FRAMEWORK FOR ESTIMATION AND POLICY ANALYSIS"

% by Eduardo Souza-Rodrigues

% This version: November 2018

% OBSERVATIONS: 
% Run this program after running "dem_def_reg.m"

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% (A) LOAD DATA & SET LABELS

% Load Estimated Coefficients and Standard Errors (calculated in "dem_def_reg.m")
%load beta_spqiv_farm_1;
load beta_spqiv_farm_2;
load beta_spqiv_farm_3;
load beta_spqiv_farm_4;

% Set of Covariates (Model Specification)
if model == 0
    
    % Main Specification    
    Names_spqiv = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Population','Prop Land Title',...
            'Fines','Dist to Ibama','W Population','W Mining','W Powerplant','W Dist to PA'};
        
elseif model == 1
    
    % No Population
    Names_spqiv = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Prop Land Title',...
            'Fines','Dist to Ibama','W Population','W Mining','W Powerplant','W Dist to PA'};
       
elseif model == 2
    
    % No land title proxy
    Names_spqiv = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Population',...
            'Fines','Dist to Ibama','W Population','W Mining','W Powerplant','W Dist to PA'};
    
elseif model == 3
    
    % No distance to ibama, nor fines
    Names_spqiv = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Population','Prop Land Title',...
            'W Population','W Mining','W Powerplant','W Dist to PA'};
    
elseif model == 4
    
    % No distance to ibama
    Names_spqiv = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Population','Prop Land Title',...
            'Fines','W Population','W Mining','W Powerplant','W Dist to PA'};

elseif model == 5
    
    % No Fines
    Names_spqiv = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Population','Prop Land Title',...
            'Dist to Ibama','W Population','W Mining','W Powerplant','W Dist to PA'};

elseif model == 6
   
    % No Spatially Lagged Regressors
    Names_spqiv = {'TC','Altitude','Temperature','Rain','Slope','Soil 2','Soil 3','Soil 4','Soil 5','Dist to PA',...
            'Mining','Powerplant','Power Plant Neighbor','Population','Prop Land Title',...
            'Fines','Dist to Ibama'};
    
end


%% (B) SHOW ESTIMATED RESULTS

disp('----------------------------------------------------------------------------')
disp('----------------------------------------------------------------------------')
disp('APPENDIX: SPQIV MEDIAN LAND-USE REGRESSIONS - (NORMALIZED) COEFFICIENTS ON ALL REGRESSORS')
disp('APPENDIX: PENALIZED SIEVES MINIMUM DISTANCE ESTIMATOR (PSMD)') 
table(round(beta_spqiv_farm_2,4),round(beta_spqiv_farm_3,4),round(beta_spqiv_farm_4,4),...
    'VariableNames',{'SMALL_MEDIUM','MEDIUM_LARGE','LARGE'},'RowNames',Names_spqiv)
disp('----------------------------------------------------------------------------')
pause

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
